package main.java.IO;
/* 打印流应用 */
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;

public class PrintWriterDemo {
    public static void main(String[] args) throws FileNotFoundException, UnsupportedEncodingException {
        //创建 PrintWriter 对象
        //1.需要手动刷新缓冲区或者关闭流
        //PrintWriter pw = new PrintWriter("./pw.txt");
        //2.自动刷新，构造方法中的true表示自动刷新
        PrintWriter pw = new PrintWriter(new FileOutputStream("./pw.txt"), true);
        //写数据
        pw.println("hello");
        pw.println("world");
        pw.println("java");
        System.out.println("写出完毕");
        //关闭流
        //pw.close();
    }
}
